package site.xuqing.androidbase.net.response;

import site.xuqing.androidbase.net.BaseResponse;

/**
 * @author xuqing
 * @Description 内置响应模板 格式：{'code':code,'message':message,'data':T}
 * @createTime 2022年04月12日 11:25:47
 */
public class CommResponse<T> extends BaseResponse<T> {
    private static int SUCCESS_CODE = 200;
    private int code;
    private String message;
    private T data;
    
    @Override
    public boolean isSuccess() {
        return getCode() == SUCCESS_CODE;
    }
    
    public static int getSuccessCode() {
        return SUCCESS_CODE;
    }
    
    public static void setSuccessCode(int successCode) {
        SUCCESS_CODE = successCode;
    }
    
    public int getCode() {
        return code;
    }
    
    public void setCode(int code) {
        this.code = code;
    }
    
    @Override
    public String getMessage() {
        return message;
    }
    
    public void setMessage(String message) {
        this.message = message;
    }
    
    @Override
    public T getData() {
        return data;
    }
    
    public void setData(T data) {
        this.data = data;
    }
    
    @Override
    public String toString() {
        return "BaseResponse{" +
            "code=" + code +
            ", message='" + message + '\'' +
            ", results=" + data +
            '}';
    }
}
